package com.itheima.steam.rabbit;

import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Class: ProducerController
 * @Package com.itheima.steam.rabbit
 * @Description: 生产消息
 * @Company: http://www.itheima.com/
 */
@RestController
public class ProducerController {
    @Resource
    private MessageProducer messageProducer;

    @GetMapping("publish/{name}")
    public void publishMessage(@PathVariable String name) {
        String message = "Hello" + name;
        Message<String> msg = MessageBuilder.withPayload(message).build();
        messageProducer.producerChannel().send(msg);
    }
}
